﻿using MediatR;
using T_Rbac_APi.Application.Command.Operator;
using T_Rbac_Rep.Interface;

namespace T_Rbac_APi.Application.CommandHandler.OperatorHandler
{
    public class OperatorUpdatestateByIdHandlers : IRequestHandler<OperatorUpdateStateByidCommand, int>
    {
        private readonly IOperator ioperator;
        

        public OperatorUpdatestateByIdHandlers(IOperator ioperator)
        {
            this.ioperator = ioperator;
        }

        public async Task<int> Handle(OperatorUpdateStateByidCommand request, CancellationToken cancellationToken)
        {
            var list = await ioperator.GetAloneByid(request.id);
            list.Ostate=request.state;
            return await ioperator.Update(list);
        }
    }
}
